import NumState from "./index";

let reducer = (state = { ...NumState.state }, action: { type: string, val: number }) => {
  let newSate = JSON.parse(JSON.stringify(state));
  for (let actionName in NumState.actionNames) {
    if (action.type === actionName) {
      NumState.actions[actionName](newSate, action)
      break;
    }
  }

  return newSate
}

export default reducer;